package com.ftd.controller;

import com.ftd.DBConnection.DBConnection;
import com.ftd.model.User;
import com.ftd.viewmodel.ApiResult;
import com.ftd.viewmodel.MapResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * Created by apple on 16/8/12.
 */
@RestController
public class UserDetailController {
    @RequestMapping("getUserDetailJson")
    public ApiResult getUerDetailJson(String phonenumber){

        ArrayList list = (ArrayList) DBConnection.select4("user");
        MapResult mapResult = new MapResult();

        for (int i = 0; i < list.size();i++) {
            User user = (User)list.get(i);
            if (user.getPhonenumber().equals(phonenumber)){
                System.out.print(user.getPhonenumber());
                System.out.print(user.getIconUrl());
                mapResult.put("iconUrl", user.getIconUrl());
                mapResult.put("phonenumber", user.getPhonenumber());
                mapResult.put("name", user.getName());

                break;
            }
        }
        return mapResult;


    }
}
